package com.pds.web.testOrganizationInfo.controller;

import com.pds.common.annotation.Log;
import com.pds.common.core.controller.BaseController;
import com.pds.common.core.domain.R;
import com.pds.common.core.page.TableDataInfo;
import com.pds.common.enums.BusinessType;
import com.pds.web.testOrganizationInfo.domain.PdsTestOrganizationPlace;
import com.pds.web.testOrganizationInfo.service.IPdsTestOrganizationPlaceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/testOrganizationPlace")
public class PdsTestOrganizationPlaceController extends BaseController {

    @Autowired
    private IPdsTestOrganizationPlaceService pdsTestOrganizationPlaceService;

    /**
     * 新增
     *
     * @param pdsTestOrganizationPlace
     * @return
     */
//    @Log(title = "机构信息新增场所信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public R<PdsTestOrganizationPlace> addPlace(@RequestBody PdsTestOrganizationPlace pdsTestOrganizationPlace) {
        return R.ok(pdsTestOrganizationPlaceService.addPlace(pdsTestOrganizationPlace));
    }

    /**
     * 删除 -- 根据id
     *
     * @param id
     * @return
     */
//    @Log(title = "机构信息删除场所信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/delete")
    public R<Boolean> deletePlace(@RequestParam Long id) {
        return R.ok(pdsTestOrganizationPlaceService.deletePlace(id));
    }

    /**
     * 更新
     *
     * @param pdsTestOrganizationPlace
     * @return
     */
//    @Log(title = "机构信息更新场所信息", businessType = BusinessType.UPDATE)
    @PutMapping("/update")
    public R<Boolean> updatePlace(@RequestBody PdsTestOrganizationPlace pdsTestOrganizationPlace) {
        return R.ok(pdsTestOrganizationPlaceService.updatePlace(pdsTestOrganizationPlace));
    }

    /**
     * 查询 -- 分页/条件：userId，status
     *
     * @param pdsTestOrganizationPlace
     * @return
     */
    @GetMapping("/list")
    public TableDataInfo listPlace(PdsTestOrganizationPlace pdsTestOrganizationPlace) {
        startPage();
        List<PdsTestOrganizationPlace> list = pdsTestOrganizationPlaceService.selectPlaceList(pdsTestOrganizationPlace);

        return getDataTable(list);
    }
}
